package com.zx.idc.backend.gui.slog;


import com.zx.idc.backend.gui.common.MongoBaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.ds.common.mongopage.Page;
import com.zx.idc.ds.httplog.entity.MonitorPageSnapshot;
import com.zx.idc.ds.httplog.repository.MonitorLogRepository;
import com.zx.idc.ds.httplog.service.IHttpLogMonitorLogService;
import com.zx.idc.ds.httplog.vo.MonitorLogVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 监测日志表 前端控制器
 * </p>
 *
 * @author chendong
 * @since 2019/4/8
 */
@RestController
@RequestMapping("/api/slogMonitorLog")
public class SlogMonitorLogController extends MongoBaseApi<IHttpLogMonitorLogService, MonitorLogVo> {

    @Autowired
    private MonitorLogRepository monitorLogRepository;

    @GetMapping("/query-page")
    @RequiresPermissions("regulatory-log:monitor-log")
    public Result<Page<MonitorLogVo>> page(Page<MonitorLogVo> page, MonitorLogVo monitorLogVo) {
        return success(service.pageByParam(page, monitorLogVo));
    }

    @GetMapping("/total")
    @RequiresPermissions("regulatory-log:monitor-log")
    public Result<Long> total() {
        return success(monitorLogRepository.count());
    }

    @GetMapping("/get/snapshot")
    @RequiresPermissions("regulatory-log:monitor-log")
    public Result<MonitorPageSnapshot> getSnapshot(MonitorLogVo monitorLogVo) {
        return success(service.getSnapshot(monitorLogVo));
    }
}
